package screen;

import javax.microedition.lcdui.Graphics;

import main.GameCanvas;
import model.Command;
import model.MyObj;

public class InfoScr extends Screen {

	private String m_title;
	public MyObj m_myObj;
	
	static InfoScr instance = null;
	public Screen backScreen;

    public static InfoScr gI() {
        if (instance == null) {
            instance = new InfoScr();
        }
        return instance;
    }
    
    public void switchToMe(String title, int width, int height, MyObj myObj, Command leftCmd, Command centerCmd, Command rightCmd) {
    	m_title = title;
    	m_cmdLeft = leftCmd;
    	m_cmdRight = rightCmd;
    	m_cmdCenter = centerCmd;
    	m_myObj = myObj;
    	
    	m_width = width;
    	m_height = height;
    	m_left = (GameCanvas.w - m_width)/2;
    	m_top = (GameCanvas.h - m_height)/2;

        backScreen = GameCanvas.currentScreen;
        super.switchToMe();
    }
	

    public void paint(Graphics g) {
        g.setClip(0, 0, GameCanvas.w, GameCanvas.h);
        backScreen.paint(g);
        g.translate(-g.getTranslateX(), -g.getTranslateY());
        
        PaintPopup.paintBoxTab(g, m_title, m_left, m_top, m_width, m_height, 0x9be5ff, 0x3c8dc0);
        
        if(m_myObj != null)
        	m_myObj.paintInfo(g, m_left + 5, m_top + 40);
      
        super.paint(g);
    }
	
	public void close() {
		// TODO Auto-generated method stub
		m_cmdCenter = null;
        m_cmdRight = null;
        m_cmdLeft = null;

        backScreen.switchToMe();
	}

	public void update() {
        backScreen.update();

    }

    
    public void paintMarqueeMsg(Graphics g){
	}
}
